package keeto.com.vn.bms.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import android.util.Log;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.IBMSProtocol;
import keeto.com.vn.bms.network.request.SendToAdminRequest;
import keeto.com.vn.bms.network.response.SendToAdminResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskSendToAdmin extends AbstractTask {
	String Group_Id;
	String Content;
	String title;	
	String authKey;
	public TaskSendToAdmin(BMSListener listener, IBMSCore core,String content,String title,String group_id, String authKey) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.Group_Id=group_id;
		this.authKey=authKey;
		this.Content=content;
		this.title=title;
	}
	
	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		SendToAdminRequest request= new SendToAdminRequest();
		request.setAuthKey(authKey);
		request.setContent(Content);
		request.setTittle(title);
		request.setGroup_Id(Group_Id);
		SendToAdminResponse response= protocol.sendToAdmin(request);
		for(BMSListener mListener:listener){
			mListener.finishSendToAdmin(response.getReturnCode(), response.getResultMsg());
		}
		
	}
	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for(BMSListener mListener:listener){
			mListener.finishSendToAdmin(IBMSProtocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, "Failed");
		}
	}
	

}
